﻿using OnlineOrder.Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace OnlineOrder.UI.管理员窗口
{
    public partial class Dish : Form
    {
        public Dish()
        {
            InitializeComponent();
        }

        private void Dish_Load(object sender, EventArgs e)
        {
            //显示商户和菜名
            try
            {
                string sql = string.Format($"SELECT BUSINESSNAME,DISHNAME,DISHPRICE FROM BUSINESS INNER JOIN DISH ON BUSINESS.BUSINESSID = DISH.BID");

                DataTable dataTable = Utils.SqlHelper.ExecuteDataTable(sql);
                this.dataGridView1.DataSource = dataTable;

            }
            catch (Exception)
            {

                throw;
            }
            dataGridView1.CellClick += dataGridView1_CellClick;
        }

        
        //选中单行回显数据
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            // 获取选中行的数据
            DataGridViewRow selectedRow = dataGridView1.Rows[e.RowIndex];
            string rowData1 = selectedRow.Cells[0].Value.ToString();
            string rowData2 = selectedRow.Cells[1].Value.ToString();
            string rowData3 = selectedRow.Cells[2].Value.ToString();
            // 在TextBox中回显选中行的数据
            textBox1.Text = rowData1;
            textBox2.Text = rowData2;
            textBox3.Text = rowData3;
        }

        //添加菜品
        private void button2_Click_1(object sender, EventArgs e)
        {
            string bName = textBox1.Text;
            string dName = textBox2.Text;
            string dprice = textBox3.Text;
        }

        //查询菜品
        private void button1_Click_1(object sender, EventArgs e)
        {
            string bName = textBox1.Text;
            string dName = textBox2.Text;
            string dprice = textBox3.Text;
            try
            {
                
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
